<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/jquery-easyui-1.3.3/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/jquery-easyui-1.3.3/themes/icon.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui-1.3.3/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/uploadPreview.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/common.js"></script>
<script type="text/javascript">

	var url;
	var changename;
	$(function(){
		$('#money1').numberbox({    
			onChange:function(newValue,oldValue){
				var money1=$('#money1').val();
			
				if(money1!=0.00){
					//保留2位小数
					$('#money2').numberbox('setValue', (money1*0.08).toFixed(2));
					$('#money3').numberbox('setValue', (money1*0.02+3).toFixed(2));
					$('#money4').numberbox('setValue', (money1*0.005).toFixed(2));
					$('#money5').numberbox('setValue', (money1*0.08).toFixed(2));
			
				}
				
			}
		});
	});
	
	function search(){
		$("#dg").datagrid('load',{
			"name":$("#sd").combobox("getValue"),
			"state":$("#s1").combobox("getValue"),
			"starttime":$('#starttime').datetimebox('getValue'),
			"endtime":$('#endtime').datetimebox('getValue')
		});
	};
	

	
	
	function saveSalarystandard(){
		var m1=$('#money1').numberbox('getValue');
		var m2=$('#money2').numberbox('getValue');
		var m3=$('#money3').numberbox('getValue');
		var m4=$('#money4').numberbox('getValue');
		var m5=$('#money5').numberbox('getValue');
		var m6=$('#money6').numberbox('getValue');
		var m7=$('#money7').numberbox('getValue');
		var m8=$('#money8').numberbox('getValue');
		var m9=$('#money9').numberbox('getValue');
		var m10=$('#money10').numberbox('getValue');
		var m11=$('#money11').numberbox('getValue');
		var m12=$('#money12').numberbox('getValue');
		var m13=$('#money13').numberbox('getValue');
		var m14=$('#money14').numberbox('getValue');
		var m15=$('#money15').numberbox('getValue');
		var temp=(Number(m1)-Number(m2)-Number(m3)-Number(m4)-Number(m5)+Number(m6)+Number(m7)+Number(m8)+Number(m9)+Number(m10)+Number(m11)+Number(m12)+Number(m13)+Number(m14)+Number(m15)).toFixed(2);
		if($('#name').val()==""){
			$.messager.alert("系统提示","薪酬标准名称不能为空！");
			return;
		}
		var total=$('#total').numberbox('setValue', temp);
		$.messager.confirm("系统提示","您确认要"+changename+"名称为<font color=blue>"+$('#name').val()+"</font><br>总额为<font color=blue>"+temp+"</font>的薪酬标准吗？",function(r){
			if(r){
				$("#fm").form("submit",{
					url:url,
					success:function(result){
						var result=eval('('+result+')');
						if(result.success){
							$.messager.alert("系统提示","登记成功");
							closeDialog();
							$("#dg").datagrid("reload");
							$('#sd').combobox('reload');      
						}else{
							$.messager.alert("系统提示","登记失败");
							return;
						}
					}
				});
			}
		});
	};
	
	function openlookDialog(){
		var selectedRows=$("#dg").datagrid('getSelections');
		if(selectedRows.length!=1){
			$.messager.alert("系统提示","请选择一条要查看的数据！");
			return;
		}
		var row=selectedRows[0];
		$("#dlg").dialog("open").dialog("setTitle","查看员工信息明细");
		$('#fm').form('load',row);
		$('#btn').linkbutton('disable');
		
	}
	
	function openModifyDialog(){
		changename="复核";
		$('#btn').linkbutton('enable');
		var selectedRows=$("#dg").datagrid('getSelections');
		if(selectedRows.length!=1){
			$.messager.alert("系统提示","请选择一条要复核的数据！");
			return;
		}
		var row=selectedRows[0];
		$("#dlg").dialog("open").dialog("setTitle","复核薪酬标准");
		$('#fm').form('load',row);

		url="${pageContext.request.contextPath}/salarystandard/setSalarystandard.action";
	}

	function resettable(){
		$('#name').val("");	
		$('#total').numberbox('setValue', (0.00).toFixed(2));
		
		$('#money1').numberbox('setValue', (0.00).toFixed(2));
		$('#money2').numberbox('setValue', (0.00).toFixed(2));
		$('#money3').numberbox('setValue', (0.00).toFixed(2));
		$('#money4').numberbox('setValue', (0.00).toFixed(2));
		$('#money5').numberbox('setValue', (0.00).toFixed(2));
		$('#money6').numberbox('setValue', (0.00).toFixed(2));
		$('#money7').numberbox('setValue', (0.00).toFixed(2));
		$('#money8').numberbox('setValue', (0.00).toFixed(2));
		$('#money9').numberbox('setValue', (0.00).toFixed(2));
		$('#money10').numberbox('setValue', (0.00).toFixed(2));
		$('#money11').numberbox('setValue', (0.00).toFixed(2));
		$('#money12').numberbox('setValue', (0.00).toFixed(2));
		$('#money13').numberbox('setValue', (0.00).toFixed(2));
		$('#money14').numberbox('setValue', (0.00).toFixed(2));
		$('#money15').numberbox('setValue', (0.00).toFixed(2));
		
	    $('#item6').val("");	
		$('#item7').val("");	
		$('#item8').val("");	
		$('#item9').val("");	
		$('#item10').val("");	
		$('#item11').val("");	
		$('#item12').val("");	
		$('#item13').val("");	
		$('#item14').val("");	
		$('#item15').val("");	
		
	}
	
	function closeDialog(){
		//$('#fm').form('clear');
		resettable();
		$("#dlg").dialog("close");
	};
	
</script>
</head>
<body style="margin:1px;">
	<table id="dg" title="薪酬标准管理" class="easyui-datagrid"
		 fitColumns="true" pagination="true" rownumbers="true" singleSelect="true" singleSelect="true"
		 url="${pageContext.request.contextPath}/salarystandard/getSalarystandardMap.action"" fit="true" toolbar="#tb">
		 <thead>
		 	<tr>
		 		<th field="cb" checkbox="true" align="center"></th>
		 		<th field="timestamp" width="150" align="center" >薪酬标准编号</th>
		 		<th field="name" width="150" align="center" >薪酬标准名称</th>
		 		<th field="total" width="150" align="center" >薪酬总额</th>
		 		<th field="registrar" width="150" align="center" >登记人</th>
		 		<th field="registtime" width="150" align="center" >登记时间</th>
		 		<th field="state" width="150" align="center" >状态</th>
		 		<th field="item1" width="150" align="center" hidden="true"></th>
		 		<th field="item2" width="150" align="center" hidden="true"></th>
		 		<th field="item3" width="150" align="center" hidden="true"></th>
		 		<th field="item4" width="150" align="center" hidden="true"></th>
		 		<th field="item5" width="150" align="center" hidden="true"></th>
		 		<th field="item6" width="150" align="center" hidden="true"></th>
		 		<th field="item7" width="150" align="center" hidden="true"></th>
		 		<th field="item8" width="150" align="center" hidden="true"></th>
		 		<th field="item9" width="150" align="center" hidden="true"></th>
		 		<th field="item10" width="150" align="center" hidden="true"></th>
		 		<th field="item11" width="150" align="center" hidden="true"></th>
		 		<th field="item12" width="150" align="center" hidden="true"></th>
		 		<th field="item13" width="150" align="center" hidden="true"></th>
		 		<th field="item14" width="150" align="center" hidden="true"></th>
		 		<th field="item15" width="150" align="center" hidden="true"></th>
		 		
		 		<th field="money1" width="150" align="center" hidden="true"></th>
		 		<th field="money2" width="150" align="center" hidden="true"></th>
		 		<th field="money3" width="150" align="center" hidden="true"></th>
		 		<th field="money4" width="150" align="center" hidden="true"></th>
		 		<th field="money5" width="150" align="center" hidden="true"></th>
		 		<th field="money6" width="150" align="center" hidden="true"></th>
		 		<th field="money7" width="150" align="center" hidden="true"></th>
		 		<th field="money8" width="150" align="center" hidden="true"></th>
		 		<th field="money9" width="150" align="center" hidden="true"></th>
		 		<th field="money10" width="150" align="center" hidden="true"></th>
		 		<th field="money11" width="150" align="center" hidden="true"></th>
		 		<th field="money12" width="150" align="center" hidden="true"></th>
		 		<th field="money13" width="150" align="center" hidden="true"></th>
		 		<th field="money14" width="150" align="center" hidden="true"></th>
		 		<th field="money15" width="150" align="center" hidden="true"></th>
		 		
		 	</tr>
		 </thead> 
	</table>
	<div id="tb">
		<div>
			<a href="javascript:openModifyDialog()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">复核薪酬标准</a>
			<a href="javascript:openlookDialog()" class="easyui-linkbutton" iconCls="icon-tip" plain="true">查看详细</a>
		</div>
		<div>
			&nbsp;薪酬标准名称：&nbsp;<input class="easyui-combobox" name="sd" id="sd" style="width: 148px;"
									data-options="
									url:'${pageContext.request.contextPath}/salarystandard/getSalarystandardName.action',
									valueField:'text',
									textField:'text',
									panelHeight:'auto'
									">
			&nbsp;登记时间：&nbsp;<input class="easyui-datetimebox" name="starttime" id="starttime" style="width: 148px;"></input>
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;：
			<input class="easyui-datetimebox" name="endtime" id="endtime" style="width: 148px;"></input>
			&nbsp;状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态：&nbsp;
							<select id="s1" class="easyui-combobox" name="s1" panelHeight="auto" style="width: 134px;">
								<option value="" ></option>
								<option value="未复核" >未复核</option>
								<option value="执行">执行</option>
							</select>
			<a href="javascript:search()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
		</div>
	</div>
	
	<div id="dlg" class="easyui-dialog" style="width: 990px;height:410px;"
	  closed="true"  closable="false" buttons="#dlg-buttons">
	 	<form id="fm"    method="post">
	 		<table >
	 			<tr><td><input name="id" id="id" type="hidden"></td></tr>
	 			<tr>
	 				<td>薪酬标准编号：</td>
	 				<td><input class="easyui-textbox" name="timestamp" id="timestamp" readonly></td>
	 				<td>薪酬标准名称：</td>
	 				<td><input class="easyui-textbox" name="name" id="name"></td>
	 				<td>薪酬总额：</td>
	 				<td><input type="text" class="easyui-numberbox"  data-options="min:0,precision:2" name="total" id="total" readonly></td>
	 			</tr>
	 			<tr>
	 				<td>登记人：</td>
	 				<td><input class="easyui-textbox" name="registrar" id="registrar" value="${currentAdmin.name }" readonly></td>
	 				<td>登记时间：</td>
	 				<td><input class="easyui-textbox" name="registtime" id="registtime" readonly></td>
	 			</tr>
	 			<tr>
	 				<td colspan="2" align="center">序号</td>
	 				<td colspan="2">薪酬项目名称</td>
	 				<td colspan="2" align="center">金额</td>
	 			</tr>
	 			<tr>
	 				<td colspan="2" align="center">1</td>
	 				<td colspan="2" ><input class="easyui-textbox" name="item1" id="item1" value="基本工资" readonly></td>
	 				<td colspan="2" align="center"><input type="text" class="easyui-numberbox"  data-options="min:0,precision:2,value:0.00" name="money1" id="money1" ></td>
	 			</tr>
	 			<tr>
	 				<td colspan="2" align="center">2</td>
	 				<td colspan="2" ><input class="easyui-textbox" name="item2" id="item2" value="养老保险" readonly></td>
	 				<td colspan="2" align="center"><input type="text" class="easyui-numberbox"  data-options="min:0,precision:2,value:0.00" name="money2" id="money2" readonly></td>
	 			</tr>
	 			<tr>
	 				<td colspan="2" align="center">3</td>
	 				<td colspan="2" ><input class="easyui-textbox" name="item3" id="item3" value="医疗保险" readonly></td>
	 				<td colspan="2" align="center"><input type="text" class="easyui-numberbox"  data-options="min:0,precision:2,value:0.00" name="money3" id="money3" readonly></td>
	 			</tr>
	 			<tr>
	 				<td colspan="2" align="center">4</td>
	 				<td colspan="2" ><input class="easyui-textbox" name="item4" id="item4" value="失业保险" readonly></td>
	 				<td colspan="2" align="center"><input type="text" class="easyui-numberbox"  data-options="min:0,precision:2,value:0.00" name="money4" id="money4" readonly></td>
	 			</tr>
	 			<tr>
	 				<td colspan="2" align="center">5</td>
	 				<td colspan="2" ><input class="easyui-textbox" name="item5" id="item5" value="住房公积金" readonly></td>
	 				<td colspan="2" align="center"><input type="text" class="easyui-numberbox"  data-options="min:0,precision:2,value:0.00" name="money5" id="money5" readonly></td>
	 			</tr>
	 			<tr>
	 				<td colspan="2" align="center">6</td>
	 				<td colspan="2" ><input class="easyui-textbox" name="item6" id="item6" ></td>
	 				<td colspan="2" align="center"><input type="text" class="easyui-numberbox"  data-options="min:0,precision:2,value:0.00" name="money6" id="money6" ></td>
	 			</tr>
	 			<tr>
	 				<td colspan="2" align="center">7</td>
	 				<td colspan="2" ><input class="easyui-textbox" name="item7" id="item7"  ></td>
	 				<td colspan="2" align="center"><input type="text" class="easyui-numberbox"  data-options="min:0,precision:2,value:0.00" name="money7" id="money7" ></td>
	 			</tr>
	 			<tr>
	 				<td colspan="2" align="center">8</td>
	 				<td colspan="2" ><input class="easyui-textbox" name="item8" id="item8"  ></td>
	 				<td colspan="2" align="center"><input type="text" class="easyui-numberbox"  data-options="min:0,precision:2,value:0.00" name="money8" id="money8" ></td>
	 			</tr>
	 			<tr>
	 				<td colspan="2" align="center">9</td>
	 				<td colspan="2" ><input class="easyui-textbox" name="item9" id="item9" ></td>
	 				<td colspan="2" align="center"><input type="text" class="easyui-numberbox"  data-options="min:0,precision:2,value:0.00" name="money9" id="money9" ></td>
	 			</tr>
	 			<tr>
	 				<td colspan="2" align="center">10</td>
	 				<td colspan="2" ><input class="easyui-textbox" name="item10" id="item10"  ></td>
	 				<td colspan="2" align="center"><input type="text" class="easyui-numberbox"  data-options="min:0,precision:2,value:0.00" name="money10" id="money10" ></td>
	 			</tr>
	 			<tr>
	 				<td colspan="2" align="center">11</td>
	 				<td colspan="2" ><input class="easyui-textbox" name="item11" id="item11"  ></td>
	 				<td colspan="2" align="center"><input type="text" class="easyui-numberbox"  data-options="min:0,precision:2,value:0.00" name="money11" id="money11" ></td>
	 			</tr>
	 			<tr>
	 				<td colspan="2" align="center">12</td>
	 				<td colspan="2" ><input class="easyui-textbox" name="item12" id="item12"  ></td>
	 				<td colspan="2" align="center"><input type="text" class="easyui-numberbox"  data-options="min:0,precision:2,value:0.00" name="money12" id="money12" ></td>
	 			</tr>
	 			<tr>
	 				<td colspan="2" align="center">13</td>
	 				<td colspan="2" ><input class="easyui-textbox" name="item13" id="item13"  ></td>
	 				<td colspan="2" align="center"><input type="text" class="easyui-numberbox"  data-options="min:0,precision:2,value:0.00" name="money13" id="money13" ></td>
	 			</tr>
	 			<tr>
	 				<td colspan="2" align="center">14</td>
	 				<td colspan="2" ><input class="easyui-textbox" name="item14" id="item14"  ></td>
	 				<td colspan="2" align="center"><input type="text" class="easyui-numberbox"  data-options="min:0,precision:2,value:0.00" name="money14" id="money14" ></td>
	 			</tr>
	 			<tr>
	 				<td colspan="2" align="center">15</td>
	 				<td colspan="2" ><input class="easyui-textbox" name="item15" id="item15"  ></td>
	 				<td colspan="2" align="center"><input type="text" class="easyui-numberbox"  data-options="min:0,precision:2,value:0.00" name="money15" id="money15" ></td>
	 			</tr>
	 			
	 			
	 		</table>
	 	</form>
	</div>
	
	<div id="dlg-buttons">
		<a href="javascript: saveSalarystandard()" id="btn" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
		<a href="javascript: closeDialog()" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>
	</div>
</body>
</html>